package speelotheek.views;

import javax.swing.JDialog;
import javax.swing.JLabel;
import java.awt.BorderLayout;
import java.text.DecimalFormat;

import javax.swing.JPanel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JTextPane;

import speelotheek.models.Statistieken;

public class Statistics extends JDialog {
	public Statistics() {
		setInitWaarden();
		setModal(true);
		setTitle("Statistieken");
		
		Statistieken stats = new Statistieken();
		
		
		JLabel lblAantalLeden = new JLabel("Aantal leden:");
		
		JLabel lblAantalStukkenSpeelgoed = new JLabel("Aantal stukken speelgoed:");
		
		JLabel lblAantalKinderen = new JLabel("Aantal kinderen");
		
		JLabel lblAantalUitleningen = new JLabel("Aantal uitleningen:");
		
		JLabel lblTotaalGeindeBoete = new JLabel("Totaalbedrag ge\u00EFnde boete:");
		
		JLabel lblLeeftijdsverloopKinderen = new JLabel("Leeftijdsverloop kinderen:");
		
		JLabel lblDreumes = new JLabel("Dreumes (1-2)");
		
		JLabel lblPeuter = new JLabel("Peuter(2-4)");
		
		JLabel lblKleuter = new JLabel("Kleuter(4-6)");
		
		JLabel lblSchoolkind = new JLabel("Schoolkind(6-12)");
		
		JLabel lblPuber = new JLabel("Puber(12-18)");
		
		JLabel lblBaby = new JLabel("Baby(0-1)");
		
		JLabel aantalLeden = new JLabel(stats.getLeden());
		
		JLabel aantalKinderen = new JLabel(stats.getKinderen());
		
		JLabel aantalSpeelgoed = new JLabel(stats.getSpeelgoed());
		
		JLabel aantalUitleningen = new JLabel(stats.getUitleningen());
		
		double d = stats.getBoetes();
        DecimalFormat df = new DecimalFormat("#.##");
		String boete = df.format(d);
		
		JLabel totaalBoete = new JLabel(boete + " euro");
		
		stats.calculateKids();
		
		JLabel aantalDreumes = new JLabel(Integer.toString(stats.getDreumesM() + stats.getDreumesV()));
		
		JLabel aantalBaby = new JLabel(Integer.toString(stats.getBabyM() + stats.getBabyV()));
		
		JLabel aantalPeuter = new JLabel(Integer.toString(stats.getPeuterM() + stats.getPeuterV()));
		
		JLabel aantalKleuter = new JLabel(Integer.toString(stats.getKleuterM() + stats.getKleuterV()));
		
		JLabel aantalSchoolkind = new JLabel(Integer.toString(stats.getSchoolkindM() + stats.getSchoolkindV()));
		
		JLabel aantalPuber = new JLabel(Integer.toString(stats.getPuberM() + stats.getPuberV()));
		
		JLabel lblTotaal = new JLabel("Totaal:");
		
		JLabel aantalBabyM = new JLabel(Integer.toString(stats.getBabyM()));
		
		JLabel aantalBabyV = new JLabel(Integer.toString(stats.getBabyV()));
		
		JLabel aantalDreumesM = new JLabel(Integer.toString(stats.getDreumesM()));
		
		JLabel aantalDreumesV = new JLabel(Integer.toString(stats.getDreumesV()));
		
		JLabel aantalPeuterM = new JLabel(Integer.toString(stats.getPeuterM()));
		
		JLabel aantalPeuterV = new JLabel(Integer.toString(stats.getPeuterV()));
		
		JLabel aantalKleuterM = new JLabel(Integer.toString(stats.getKleuterM()));
		
		JLabel aantalKleuterV = new JLabel(Integer.toString(stats.getKleuterV()));
		
		JLabel aantalSchoolkindM = new JLabel(Integer.toString(stats.getSchoolkindM()));
		
		JLabel aantalSchoolkindV = new JLabel(Integer.toString(stats.getSchoolkindV()));
		
		JLabel aantalPuberM = new JLabel(Integer.toString(stats.getPuberM()));
		
		JLabel aantalPuberV = new JLabel(Integer.toString(stats.getPuberV()));
		
		JLabel lblJongens = new JLabel("Jongens:");
		
		JLabel lblMeisjes = new JLabel("Meisjes:");
		GroupLayout groupLayout = new GroupLayout(getContentPane());
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.TRAILING)
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap(16, GroupLayout.PREFERRED_SIZE)
					.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
						.addGroup(groupLayout.createSequentialGroup()
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(lblTotaalGeindeBoete)
								.addComponent(lblAantalUitleningen)
								.addComponent(lblAantalStukkenSpeelgoed)
								.addComponent(lblAantalKinderen)
								.addComponent(lblAantalLeden)
								.addComponent(lblLeeftijdsverloopKinderen))
							.addGap(24))
						.addGroup(groupLayout.createSequentialGroup()
							.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
								.addComponent(lblMeisjes)
								.addComponent(lblJongens)
								.addComponent(lblTotaal))
							.addGap(18)
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(lblBaby)
								.addComponent(aantalBaby)
								.addComponent(aantalBabyM)
								.addComponent(aantalBabyV))
							.addPreferredGap(ComponentPlacement.UNRELATED)
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(lblDreumes)
								.addComponent(aantalDreumes)
								.addComponent(aantalDreumesM)
								.addComponent(aantalDreumesV))
							.addPreferredGap(ComponentPlacement.RELATED, 20, Short.MAX_VALUE)))
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(33)
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(aantalKinderen)
								.addComponent(aantalLeden)
								.addComponent(aantalSpeelgoed)
								.addComponent(aantalUitleningen)
								.addComponent(totaalBoete)))
						.addGroup(groupLayout.createSequentialGroup()
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(lblPeuter)
								.addComponent(aantalPeuter)
								.addComponent(aantalPeuterM)
								.addComponent(aantalPeuterV))
							.addPreferredGap(ComponentPlacement.UNRELATED)
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(lblKleuter)
								.addComponent(aantalKleuter)
								.addComponent(aantalKleuterM)
								.addComponent(aantalKleuterV))
							.addPreferredGap(ComponentPlacement.UNRELATED)
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(lblSchoolkind)
								.addComponent(aantalSchoolkind)
								.addComponent(aantalSchoolkindM)
								.addComponent(aantalSchoolkindV))
							.addPreferredGap(ComponentPlacement.UNRELATED)
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(aantalPuberV)
								.addComponent(aantalPuberM)
								.addComponent(aantalPuber)
								.addComponent(lblPuber))))
					.addGap(66))
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addGap(58)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblAantalLeden)
						.addComponent(aantalLeden))
					.addGap(18)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblAantalKinderen)
						.addComponent(aantalKinderen))
					.addGap(18)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblAantalStukkenSpeelgoed)
						.addComponent(aantalSpeelgoed))
					.addGap(18)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblAantalUitleningen)
						.addComponent(aantalUitleningen))
					.addGap(18)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblTotaalGeindeBoete)
						.addComponent(totaalBoete))
					.addGap(53)
					.addComponent(lblLeeftijdsverloopKinderen)
					.addGap(28)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblBaby)
						.addComponent(lblDreumes)
						.addComponent(lblPeuter)
						.addComponent(lblKleuter)
						.addComponent(lblSchoolkind)
						.addComponent(lblPuber))
					.addGap(18)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(aantalDreumes)
						.addComponent(aantalBaby)
						.addComponent(aantalPeuter)
						.addComponent(aantalKleuter)
						.addComponent(aantalSchoolkind)
						.addComponent(aantalPuber)
						.addComponent(lblTotaal))
					.addGap(18)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(aantalBabyM)
						.addComponent(aantalDreumesM)
						.addComponent(aantalPeuterM)
						.addComponent(aantalKleuterM)
						.addComponent(aantalSchoolkindM)
						.addComponent(aantalPuberM)
						.addComponent(lblJongens))
					.addGap(18)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(aantalBabyV)
						.addComponent(aantalDreumesV)
						.addComponent(aantalPeuterV)
						.addComponent(aantalKleuterV)
						.addComponent(aantalSchoolkindV)
						.addComponent(aantalPuberV)
						.addComponent(lblMeisjes))
					.addContainerGap(56, Short.MAX_VALUE))
		);
		getContentPane().setLayout(groupLayout);
	}
	
	private void setInitWaarden(){
    	
    	this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    	
    	setBounds(0, 0, 600, 500);
    	setLocationRelativeTo(null); // Dialog scherm in het midden
    }
}
